<script setup lang="ts">
import { computed, inject, useSlots } from 'vue'
import type { VxeColumnPropTypes } from 'vxe-table/types/column'

const props = withDefaults(
    defineProps<{
        /**
         * 将列固定在左侧或者右侧
         */
        fixed?: VxeColumnPropTypes.Fixed
        /**
         * 列字段名
         */
        field?: VxeColumnPropTypes.Field
    }>(),
    {}
)

const slots = useSlots()

const currentTable: any = inject('currentTable', null)

const fixed = computed(() => {
    //一旦进入拖拽模式，就不允许固定列，因为样式 会乱
    return currentTable?.props.dragable ? null : props.fixed
})
</script>

<template>
    <vxe-column :fixed="fixed" :field="field">
        <template v-for="(_item, key) in slots" :key="key" #[key]="data">
            <slot :name="key" v-bind="data ?? {}" />
        </template>
    </vxe-column>
</template>

<style scoped></style>
